package com.tsunami.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tsunami.base.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 组织人员职业类型
 *
 * @author lx
 * @since 2023/3/1 18:10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "组织人员职业类型-枚举")
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum CareerType implements BaseEnum {
    /**
     * teacher="教师"
     */
    teacher("教师"),
    /**
     * MASTER="班主任"
     */
    master("班主任"),
    /**
     * STUDENT="学生"
     */
    student("学生"),
    /**
     * PARENT="家长"
     */
    parent("家长"),
    /**
     * admin="管理员"
     */
    admin("管理员"),
    /**
     * subadmin="子管理员"
     */
    subadmin("子管理员"),
    /**
     * CLERK="职员"
     */
    clerk("职员"),
    /**
     * USER="用户"
     */
    user("用户"),
    /**
     * AUDIT="审核员"
     */
    audit("审核员"),
    /**
     * AUDIT="审核员"
     */
    house("宿管"),
    /**
     * security="保安"
     */
    security("保安"),
    /**
     * officer="办理人员"
     */
    officer("办理人员"),
    /**
     * assetsAdmin="资产管理人员"
     */
    assetsAdmin("资产管理人员"),
    ;

    @Schema(description = "描述")
    private String desc;


    public static CareerType match(String val, CareerType def) {
        for (CareerType enm : CareerType.values()) {
            if (enm.name().equalsIgnoreCase(val)) {
                return enm;
            }
        }
        return def;
    }

    public static CareerType get(String val) {
        return match(val, null);
    }

    public boolean eq(String val) {
        return this.name().equalsIgnoreCase(val);
    }

    public boolean eq(CareerType val) {
        if (val == null) {
            return false;
        }
        return eq(val.name());
    }


    @Override
    public String getCode() {
        return BaseEnum.super.getCode();
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
